#pragma once

#include <string>
#include <stdint.h>

#ifdef _UNICODE
using _tstring = std::wstring;
#else
using _tstring = std::string;
#endif

class CCrc32Utils
{
public:

    static uint32_t GetCrc32Value(const void* lpData, size_t nSize);
    static _tstring GetCrc32Str(const void* lpData, size_t nSize, bool bUpper = false);
    static uint32_t GetFileCrc32Value(const _tstring& strFilePath);
    static _tstring GetFileCrc32Str(const _tstring& strFilePath, bool bUpper = false);

    static uint32_t GetPartCrc32(uint32_t crcInit, const void* lpData, size_t byteSize);
    static _tstring GetStrFromValue(uint32_t uCrc32, bool bUpper = false);

private:

    static void InitCrc32Table(void);
    static uint32_t GetCrc32(const uint8_t* lpData, size_t byteSize);
    static uint32_t GetCrc32Data(uint32_t crcInit, const uint8_t* lpData, size_t byteSize);
};